package com.itheima.reggie.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.itheima.reggie.converter.LocalDateTimeConverter;
import com.itheima.reggie.converter.LongConverter;
import com.itheima.reggie.converter.StringSexConverter;
import com.itheima.reggie.converter.IntegerStatusConverter;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;

    @ExcelProperty(value = "用户id", index = 0,converter = LongConverter.class)
    private Long id;

    @ExcelProperty(value = "账户名", index = 1)
    private String username;

    @ExcelProperty(value = "用户名", index = 2)
    private String name;

    @ExcelIgnore
    private String password;

    @ExcelProperty(value = "手机号码", index = 3)
    private String phone;

    @ExcelProperty(value = "性别", index = 4 , converter = StringSexConverter.class)
    private String sex;

    @ExcelProperty(value = "身份证号码", index = 5)
    private String idNumber; //身份证号码  驼峰命名法 ---> 映射的字段名为 id_number

    @ExcelProperty(value = "启用状态", index = 6,converter = IntegerStatusConverter.class)
    private Integer status;

   // @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    @ExcelProperty(value = "创建时间", index = 7,converter = LocalDateTimeConverter.class)
    private LocalDateTime createTime;

    //@JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ExcelProperty(value = "修改时间", index = 8,converter = LocalDateTimeConverter.class)
    private LocalDateTime updateTime;

    @TableField(fill = FieldFill.INSERT)
    @ExcelIgnore
    private Long createUser;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ExcelIgnore
    private Long updateUser;

    @TableField(exist = false)
    @ExcelProperty(value = "创建人姓名", index = 9)
    private String createUserName;

    @TableField(exist = false)
    @ExcelProperty(value = "修改人姓名", index = 10)
    private String updateUserName;
}